package com.pms.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.pms.pojo.Department;
import com.pms.pojo.Employee;
import com.pms.pojo.Post;
import com.pms.pojo.Require_yun;
import com.pms.service.EmployeePeriodService;

@Controller
@RequestMapping("/period")
public class PersonnelPeriodController {
	@Resource(name="periodService")
	private EmployeePeriodService  employeePeriod;
	
	public void setEmployeePeriod(EmployeePeriodService employeePeriod) {
		this.employeePeriod = employeePeriod;
	}


	@RequestMapping("/enterPeriod")
	public String enterPeriod(Model model) throws Exception{
		List<Department> DepartmentList = employeePeriod.getDpartments();
		List<Post> PostList = employeePeriod.getPosts();
		model.addAttribute("department", DepartmentList);
		model.addAttribute("post", PostList);
		return "personnel_period";
	}
	
	
	@RequestMapping("/enterOperation")
	public String enterOperation(Require_yun require,Model model) throws Exception{
		List<Department> DepartmentList = this.employeePeriod.getDpartments();
		List<Post> PostList = this.employeePeriod.getPosts();
		Require_yun require_yun = this.employeePeriod.getRequireOp_yun(require);
		model.addAttribute("department", DepartmentList);
		model.addAttribute("post", PostList);
		model.addAttribute("require_yun", require_yun);
		model.addAttribute("empId", require.getEmpId());
		return "employee_operation";
	}
	
	
	@RequestMapping("/enterInquiry")
	public String enterInquiry(Model model) throws Exception{
		List<Department> DepartmentList = employeePeriod.getDpartments();
		List<Post> PostList = employeePeriod.getPosts();
		model.addAttribute("department", DepartmentList);
		model.addAttribute("post", PostList);
		return "chang_employee_inquiry";
	}
	
	@RequestMapping("/getRequire")
	public String getRequire(Require_yun require,Model model) throws Exception{
		List<Department> DepartmentList = this.employeePeriod.getDpartments();
		List<Post> PostList = this.employeePeriod.getPosts();
		List<Require_yun> require_yun = this.employeePeriod.getRequire_yun(require);
		model.addAttribute("department", DepartmentList);
		model.addAttribute("post", PostList);
		model.addAttribute("require_yun", require_yun);
		return "personnel_period";
	}
	
	@RequestMapping("/getRequireTwo")
	public String getRequireTwo(Require_yun require,Model model) throws Exception{
		List<Department> DepartmentList = this.employeePeriod.getDpartments();
		List<Post> PostList = this.employeePeriod.getPosts();
		List<Require_yun> require_yun = this.employeePeriod.getRequireTwo_yun(require);
		model.addAttribute("department", DepartmentList);
		model.addAttribute("post", PostList);
		model.addAttribute("require_yun", require_yun);
		return "chang_employee_inquiry";
	}
	@RequestMapping("/upRegemp")
	 public String upRegemp(Integer empId) {
		this.employeePeriod.updateRegemp(empId);
		return "employee_operation";
	}
	@RequestMapping("/updateNever")
	 public String updateNever(Integer empId) {
		this.employeePeriod.updateNever(empId);
		return "employee_operation";
	}
	@RequestMapping("/updateDela")
	 public String updateDela(Require_yun require,Model model) {
		this.employeePeriod.updateDela(require);
		return "employee_operation";
	}
	@RequestMapping("/updateEva")
	 public String updateEva(Require_yun require,Model model) {
		Require_yun require_yun = this.employeePeriod.getRequireOp_yun(require);
		model.addAttribute("require_yun", require_yun);
		this.employeePeriod.updateEva(require);
		return "employee_operation";
	}
}
